﻿#include <iostream>
#include "httpRequest.h"
#include "encoder.hpp"
int main()
{
	cool::Request http;
	auto cb = [](double total, double now)->bool {
		if (total > 0 && now > 0)
		{
			std::cout << (now / total) * 100 << std::endl;
		}
		return true;
	};
	cool::downUpInfo info(true,cb);
	std::vector<cool::UpFromInfo> upinfo;
	upinfo.emplace_back(cool::UpFromInfo("file", R"(C:\Users\Administrator\Pictures\8.png)", cool::from_type::LOCAL_FILE_PATH));
	cool::header h;
	std::string times = std::to_string(time(NULL));
	h << "referer: https://imgurl.org/";
	h << "x-requested-with: XMLHttpRequest";
	h << "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.57";
	auto res = http.req_redirection(false).req_header(h).\
		Upfile("https://imgurl.org/upload/ftp", upinfo,&info);
	std::cout << cool::Encoder::utf8_to_ansi(res->res_text()) << std::endl;
	//std::cout << cool::Encoder::utf8_to_ansi(res->res_headers()) << std::endl;
	std::cout << res->res_cookies_text() << std::endl;
	std::cout << res->res_http_code() << std::endl;

	return 0;
}